#include <any/Any.h>
#include <any/any.hpp>
#include <gtest/gtest.h>

using tpl::Any;

#include <string>
using std::string;
//
TEST(Any, empty)
{
  EXPECT_EQ(Any{}.IsEmpty(), true);

  Any a;
  EXPECT_EQ(a.IsEmpty(), true);
  a = 1;
  EXPECT_EQ(a.IsEmpty(), false);
}

TEST(Any, type)
{
  EXPECT_EQ(Any{}.IsType<void>(), true);
  EXPECT_EQ(Any{}.IsType<double>(), false);

  Any a;
  EXPECT_EQ(a.IsType<void>(), true);
  a = 1;
  EXPECT_EQ(a.IsType<int>(), true);

  a = 1.0f;
  EXPECT_EQ(a.IsType<float>(), true);

  a = 2.1;
  EXPECT_EQ(a.IsType<double>(), true);

  a = string("hello");
  EXPECT_EQ(a.IsType<string>(), true);


  Any b = 1;
  EXPECT_EQ(b.IsType<int>(), true);

  b = 1.1;
  EXPECT_EQ(b.IsType<double>(), true);

  int v = 211;
  Any p = &v;
  EXPECT_EQ(p.IsType<int*>(), true);
  EXPECT_EQ(*tpl::AnyCast<int*>(p), v);

  // b = "hello";
}


TEST(Any, cast)
{
  int vv = 1;
  Any a =vv;
}